//
//  AppDelegatePresenter.m
//  StockpdfReading
//
//  Created by mac on 2017/7/21.
//  Copyright © 2017年 上海LOL信息技术服务有限公司. All rights reserved.
//

#import "AppDelegatePresenter.h"
#import "AppStartModel.h"
#import "Interface.h"
#import "AppStartModel.h"


@implementation AppDelegatePresenter

-(void)requestAppStartBlock:(ResultBlock)block{
    
    NSString * currentversion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
    AVQuery *query = [AVQuery queryWithClassName:@"AppCheck"];
    [query whereKey:@"appVersion" equalTo:currentversion];
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error && objects.count > 0) {
            AVObject *object = objects.firstObject;
            [SRTool writeValue:object[@"isCheck"] forKey:isinCheck];
            block(YES,@"请求成功");
        }else{
            [SRTool writeValue:@"1" forKey:isinCheck];
            block(NO,@"服务器异常.");
        }
    }];
    
    
}


-(void)requestWebURL:(ResultBlock)block{
    [[Interface shareInstance]request:POST baseUrl:appStartWebURL urlString:nil parameters:nil platformType:PlatformTypeNone isEncrypted:NO finished:^(id responseObject, NSError *error) {
        if (responseObject) {
            NSDictionary * redic = responseObject[@"data"][0];
            AppStartModel *model = [AppStartModel mj_objectWithKeyValues:redic];
            YYCache *yyCache=[YYCache cacheWithName:TYCacheName];
            [yyCache setObject:model forKey:TYCacheCheckKey];
            block(YES,@"没问题");
        }else{
            block(NO,@"有问题");
        }
    }];
}





@end




